<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" import="pojo.*,service.*,base.*,java.sql.Timestamp;"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script> 
function tiao(){
	location.href="../../website/regest.jsp";
	};
	setTimeout(tiao,1000);
	</script>
</head>
<body>
<%
    request.setCharacterEncoding("utf-8");
	String username = request.getParameter("username").trim();
	String password = request.getParameter("password").trim();
	Timestamp registertime=new Timestamp(System.currentTimeMillis());
	MemberService service = new MemberService();
	MemberLogin mem=service.getMember(username);
	if(mem!=null){
		out.print("用户名已存在 ！请重新注册 <a href='../../website/regest.jsp'>注册</a>");
	}
	else{
    int r =  service.register(username,password,registertime);
 
    int m=service.add(r);
    if(m==1){
	
	session.setAttribute("name",username);
	session.setAttribute("id",r);
	response.sendRedirect("../../website/index.jsp");
	}
	else out.print("登陆失败 ！请重新登陆 <a href='../../website/login.jsp'>返回</a>");
	}
%>
</body>
</html>
